// ignore_for_file: constant_identifier_names, avoid_print



import '../../../models/response.dart';
import '../core/hi_net.dart';
import '../request/base_request.dart';

import '../request/register_request.dart';

/// 与服务端通信 , 数据交互和持久化的操作都放在 DAO 层:
class RegisterDao {
  static register(String userName, String password) async {
    return await _send(userName, password);
  }

  static _send(
    String userName,
    String password,
  ) async {
    BaseRequest request;
    // 登录请求
    request = RegisterRequest();
    // 为 request 添加参数:
    request
        .addJson("username", userName)
        .addJson("password", password)
        .addJson("email", "cilanguser@gmail.com")
        .addHeader("Content-Type", "application/json");

    var result = await HiNet.getInstance().fire(request);
    print("register_dao: $result");
    TiebaResponse response = TiebaResponse.fromMap(result);
    return response;
  }
}
